// AboutDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MailStat.h"
#include "AboutDlg.h"
#include "AppTools.h"

// CAboutDlg dialog

IMPLEMENT_DYNAMIC(CAboutDlg, CDialog)

CAboutDlg::CAboutDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAboutDlg::IDD, pParent)
{
	m_hDialogBrush = CreateSolidBrush(DLG_BK_COLOR);

}

CAboutDlg::~CAboutDlg()
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	ON_WM_CTLCOLOR()
	ON_WM_NCHITTEST()
	ON_BN_CLICKED(IDC_BTN_HELP, &CAboutDlg::OnBnClickedBtnHelp)
	ON_BN_CLICKED(IDC_BTN_GET_LOG, &CAboutDlg::OnBnClickedBtnGetLog)
	ON_BN_CLICKED(IDC_BTN_SUPPORT, &CAboutDlg::OnBnClickedBtnSupport)
END_MESSAGE_MAP()


// CAboutDlg message handlers

HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

	if(nCtlColor == CTLCOLOR_STATIC)  
	{  
		pDC->SetTextColor(RGB(0,0,0));  
		pDC->SetBkColor(DLG_BK_COLOR);  
		return m_hDialogBrush;
	}
	else if (nCtlColor == CTLCOLOR_DLG)
	{
		//pDC->SetTextColor(COLOR_DLG_VC);
		return m_hDialogBrush;
	}
	return m_hDialogBrush;
}

BOOL CAboutDlg::PtInClientRect(CPoint p)
{
	CRect rc;
	GetClientRect(&rc);
	ClientToScreen(&rc);
	return rc.PtInRect(p);
}


LRESULT CAboutDlg::OnNcHitTest(CPoint point)
{
	return PtInClientRect(point) ? HTCAPTION : CDialog::OnNcHitTest(point);
}


BOOL CAboutDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_btnOK.SubclassDlgItem(IDOK, this);
	m_btnOK.SetColor(CButtonST::BTNST_COLOR_BK_OUT,SUB_BTN1_COLOR);
	m_btnOK.SetColor(CButtonST::BTNST_COLOR_BK_IN,SUB_BTN1_SEL_COLOR);
	m_btnOK.SetColor(CButtonST::BTNST_COLOR_BK_FOCUS,SUB_BTN1_COLOR);
	m_btnOK.SetColor(CButtonST::BTNST_COLOR_FG_IN,SUB_BTN1_FONT_FOCUS_COLOR);
	m_btnOK.SetColor(CButtonST::BTNST_COLOR_FG_OUT,SUB_BTN1_FONT_COLOR);
	m_btnOK.SetColor(CButtonST::BTNST_COLOR_FG_FOCUS,SUB_BTN1_FONT_COLOR);

	m_btnHelp.SubclassDlgItem(IDC_BTN_HELP, this);
	m_btnHelp.SetColor(CButtonST::BTNST_COLOR_BK_OUT,SUB_BTN1_COLOR);
	m_btnHelp.SetColor(CButtonST::BTNST_COLOR_BK_IN,SUB_BTN1_SEL_COLOR);
	m_btnHelp.SetColor(CButtonST::BTNST_COLOR_BK_FOCUS,SUB_BTN1_COLOR);
	m_btnHelp.SetColor(CButtonST::BTNST_COLOR_FG_IN,SUB_BTN1_FONT_FOCUS_COLOR);
	m_btnHelp.SetColor(CButtonST::BTNST_COLOR_FG_OUT,SUB_BTN1_FONT_COLOR);
	m_btnHelp.SetColor(CButtonST::BTNST_COLOR_FG_FOCUS,SUB_BTN1_FONT_COLOR);

	m_btnSupport.SubclassDlgItem(IDC_BTN_SUPPORT, this);
	m_btnSupport.SetColor(CButtonST::BTNST_COLOR_BK_OUT,SUB_BTN3_COLOR);
	m_btnSupport.SetColor(CButtonST::BTNST_COLOR_BK_IN,SUB_BTN3_SEL_COLOR);
	m_btnSupport.SetColor(CButtonST::BTNST_COLOR_BK_FOCUS,SUB_BTN3_COLOR);
	m_btnSupport.SetColor(CButtonST::BTNST_COLOR_FG_IN,SUB_BTN3_FONT_FOCUS_COLOR);
	m_btnSupport.SetColor(CButtonST::BTNST_COLOR_FG_OUT,SUB_BTN3_FONT_COLOR);
	m_btnSupport.SetColor(CButtonST::BTNST_COLOR_FG_FOCUS,SUB_BTN3_FONT_COLOR);

	m_btnGetLog.SubclassDlgItem(IDC_BTN_GET_LOG, this);
	m_btnGetLog.SetColor(CButtonST::BTNST_COLOR_BK_OUT,SUB_BTN_COLOR);
	m_btnGetLog.SetColor(CButtonST::BTNST_COLOR_BK_IN,SUB_BTN_SEL_COLOR);
	m_btnGetLog.SetColor(CButtonST::BTNST_COLOR_BK_FOCUS,SUB_BTN_COLOR);
	m_btnGetLog.SetColor(CButtonST::BTNST_COLOR_FG_IN,SUB_BTN_FONT_FOCUS_COLOR);
	m_btnGetLog.SetColor(CButtonST::BTNST_COLOR_FG_OUT,SUB_BTN_FONT_COLOR);
	m_btnGetLog.SetColor(CButtonST::BTNST_COLOR_FG_FOCUS,SUB_BTN_FONT_COLOR);


	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}

void CAboutDlg::OnBnClickedBtnHelp()
{
	ShellExecute(0, _T("open"), _T("http://www.mobitnt.com/stat/install.php"), NULL, NULL, SW_SHOWNORMAL);
}

void CAboutDlg::OnBnClickedBtnGetLog()
{
	TCHAR szLogPath[MAX_PATH];
	GetAppDataPath(szLogPath);

	ShellExecute(NULL,_T("open"),szLogPath,NULL,NULL,SW_SHOW);
}

void CAboutDlg::OnBnClickedBtnSupport()
{
	ShellExecute(0, _T("open"),_T("mailto:support@mobitnt.com"), NULL, NULL, SW_SHOWNORMAL);
}
